<!DOCTYPE html>
<html >
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>弹幕</title>
    <style>
        .wrap{
            width: 800px;
            margin: 40px auto;
        }
        .video{
            width: 100%;
            min-height: 400px;
            border: 1px solid #999;
            border-radius: 6px;
            position: relative;
            overflow: hidden; 
        }
        .video span{
            position: absolute;
            right: -120px;
            top: 50px;
        }
        .dm{
            margin: 20px 0;
            width: 100%;
            box-sizing: border-box;
        }
        input{
            width: 720px;
            height: 30px;
            padding: 0 10px;
            border: 1px solid #999;
            border-radius: 4px;
        }
        button{
            height: 30px;
            padding: 0 10px;
            color: #fff;
            border: none;
            border-radius: 4px;
            background-color: royalblue;
        }
        input,button{
            outline: none;
        }

    </style>
</head>
<body>
    <div class="wrap">
        <div class="video">
            <span></span>
           

        </div>
        <div class="dm">
            <input type="text">
            <button>发送</button>
        </div>
    </div>
    
</body>
<script>
    let text = document.querySelector('text');
    let btn = document.querySelector('button');
 
    let timer;

    btn.addEventListener('click', e => {
        timer = setInterval(() => {
            let x = s1.offsetLeft;

            if(x > -120){
                s1.style.left = x - 1 + 'px';
            }

            if(x <= -120){
                clearInterval(timer);
            }
        }, 5);

    });


</script>
</html>